<?php
//Author: Emmanuel Buckley Date Started: April 2, 2012 Date Modified: April 5, 2012

Class EventViewer
{
	public $sql = " ";
	public $dbConn;
	public $numFields;
	public $exec;
	public $col = array();
	public $dataTable;
	
	//sets the view all events SQL
	public function viewAllSQL()
	{
		$sql = "Select * from Event";
	}
	
	//view data by eventID
	public function eventIDView($eventID)
	{
		//$sql = "Select * from Event where EventID =" $eventID; 
	}
	
	//sets database connection
	public function openDBConnection()
	{
		$dbConn = odbc_connect('EventDB','','');
	}
	
	//executes query when called
	public function execQuery()
	{
		$exec = odbc_exec($dbConn,$sql);
	}
	
	//executes number of fields when called
	public function setFieldNumber()
	{
		$numFields = odbc_num_fields($exec);
	}
	
	//returns the entire event database table structure
	public function eventTableStructure()
	{
		$table = "<table border='1'><tr><th>EventID</th><th>EventName</th><th>Price</th><th>Date</th><th>Ad_ID</th><th>SponsorID</th><th>VenueID</th><th>Time</th></tr>";
		return ($table);
	}
	
	//populates table
	public function getEventData()
	{
		while($row=odbc_fetch_row($exec))
		{
			for($i=1;$i<$numFields+1;$i++)
			{
				$col[$i]=odbc_result($exec,$i);
				$dataTable +="<td>".$col[$i]."</td>";
			}
			
			$data = "<tr>" + $dataTable + "</tr>";
			return ($data);
		}
	}
	
	
	
	


}

?>